//===----------------------------------------------------------------------===//
//
// This source file is part of the Soto for AWS open source project
//
// Copyright (c) 2017-2021 the Soto project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of Soto project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//

// THIS FILE IS AUTOMATICALLY GENERATED by https://github.com/soto-project/soto/tree/main/CodeGenerator. DO NOT EDIT.

import SotoCore

/// Error enum for Translate
public struct TranslateErrorType: AWSErrorType {
    enum Code: String {
        case concurrentModificationException = "ConcurrentModificationException"
        case conflictException = "ConflictException"
        case detectedLanguageLowConfidenceException = "DetectedLanguageLowConfidenceException"
        case internalServerException = "InternalServerException"
        case invalidFilterException = "InvalidFilterException"
        case invalidParameterValueException = "InvalidParameterValueException"
        case invalidRequestException = "InvalidRequestException"
        case limitExceededException = "LimitExceededException"
        case resourceNotFoundException = "ResourceNotFoundException"
        case serviceUnavailableException = "ServiceUnavailableException"
        case textSizeLimitExceededException = "TextSizeLimitExceededException"
        case tooManyRequestsException = "TooManyRequestsException"
        case unsupportedLanguagePairException = "UnsupportedLanguagePairException"
    }

    private let error: Code
    public let context: AWSErrorContext?

    /// initialize Translate
    public init?(errorCode: String, context: AWSErrorContext) {
        guard let error = Code(rawValue: errorCode) else { return nil }
        self.error = error
        self.context = context
    }

    internal init(_ error: Code) {
        self.error = error
        self.context = nil
    }

    /// return error code string
    public var errorCode: String { self.error.rawValue }

    /// Another modification is being made. That modification must complete before you can make your change.
    public static var concurrentModificationException: Self { .init(.concurrentModificationException) }
    /// There was a conflict processing the request. Try your request again.
    public static var conflictException: Self { .init(.conflictException) }
    /// The confidence that Amazon Comprehend accurately detected the source language is low. If a low confidence level is acceptable for your application, you can use the language in the exception to call Amazon Translate again. For more information, see the DetectDominantLanguage operation in the Amazon Comprehend Developer Guide.
    public static var detectedLanguageLowConfidenceException: Self { .init(.detectedLanguageLowConfidenceException) }
    /// An internal server error occurred. Retry your request.
    public static var internalServerException: Self { .init(.internalServerException) }
    /// The filter specified for the operation is invalid. Specify a different filter.
    public static var invalidFilterException: Self { .init(.invalidFilterException) }
    /// The value of the parameter is invalid. Review the value of the parameter you are using to correct it, and then retry your operation.
    public static var invalidParameterValueException: Self { .init(.invalidParameterValueException) }
    ///  The request that you made is invalid. Check your request to determine why it's invalid and then retry the request.
    public static var invalidRequestException: Self { .init(.invalidRequestException) }
    /// The specified limit has been exceeded. Review your request and retry it with a quantity below the stated limit.
    public static var limitExceededException: Self { .init(.limitExceededException) }
    /// The resource you are looking for has not been found. Review the resource you're looking for and see if a different resource will accomplish your needs before retrying the revised request.
    public static var resourceNotFoundException: Self { .init(.resourceNotFoundException) }
    /// The Amazon Translate service is temporarily unavailable. Please wait a bit and then retry your request.
    public static var serviceUnavailableException: Self { .init(.serviceUnavailableException) }
    ///  The size of the text you submitted exceeds the size limit. Reduce the size of the text or use a smaller document and then retry your request.
    public static var textSizeLimitExceededException: Self { .init(.textSizeLimitExceededException) }
    ///  You have made too many requests within a short period of time. Wait for a short time and then try your request again.
    public static var tooManyRequestsException: Self { .init(.tooManyRequestsException) }
    /// Amazon Translate does not support translation from the language of the source text into the requested target language. For more information, see how-to-error-msg.
    public static var unsupportedLanguagePairException: Self { .init(.unsupportedLanguagePairException) }
}

extension TranslateErrorType: Equatable {
    public static func == (lhs: TranslateErrorType, rhs: TranslateErrorType) -> Bool {
        lhs.error == rhs.error
    }
}

extension TranslateErrorType: CustomStringConvertible {
    public var description: String {
        return "\(self.error.rawValue): \(self.message ?? "")"
    }
}
